package com.huwei.util.cryption;

import org.springframework.beans.factory.annotation.Value;

/**
 * jwt 参数设定
 * @author huwei
 *
 */
public class AuthenConstants {
	final static public Long TOKEN_EXP_TIME = Long.valueOf(20 * 60 * 1000);
	final static public Long TOKEN_GRA_TIME = Long.valueOf(TOKEN_EXP_TIME * 2);
	final static public String DEFAULT_ISSUSER = "AUTHEN_CENTER";
	final static public String DEFAULT_AUDIENCE = "CLIENT";
	
	final static public AuthenConstants DEFUALT = new AuthenConstants();
	/*
	 * 过期时间
	 */
	@Value("${jwt.token.exp.time}")
	private Long tokenExpTime;
	/*
	 * 宽限时间，即最终过期时间
	 */
	@Value("${jwt.token.gra.time}")
	private Long tokeGraTime;
	/*
	 * token 签发主体
	 */
	@Value("${jwt.issuser}")
	private String issuser;
	
	/*
	 * jwt的接受对象
	 */
	@Value("${jwt.audience}")
	private String audience;

	public Long getTokenExpTime() {
		return tokenExpTime;
	}

	public void setTokenExpTime(Long tokenExpTime) {
		this.tokenExpTime = tokenExpTime;
	}

	public Long getTokeGraTime() {
		return tokeGraTime;
	}

	public void setTokeGraTime(long tokeGraTime) {
		this.tokeGraTime = tokeGraTime;
	}

	public String getIssuser() {
		return issuser;
	}

	public void setIssuser(String issuser) {
		this.issuser = issuser;
	}

	public String getAudience() {
		return audience;
	}

	public void setAudience(String audience) {
		this.audience = audience;
	}

	public AuthenConstants(Long tokenExpTime, Long tokeGraTime, String issuser, String audience) {
		this.tokenExpTime = tokenExpTime;
		this.tokeGraTime = tokeGraTime;
		this.issuser = issuser;
		this.audience = audience;
	}
	
	public AuthenConstants(String issuser, String audience) {
		this(TOKEN_EXP_TIME ,TOKEN_GRA_TIME ,issuser ,audience);
	}
	
	public AuthenConstants() {
		this(DEFAULT_ISSUSER ,DEFAULT_AUDIENCE);
	}
	
}
